#include <boost/static_assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/foreach.hpp>
#include <boost/type_traits.hpp>

#include "config.h"
#include "matrix.h"
#include "primitive.h"
#include "integer.h"
#include "predicate_2d.h"
#include "predicate_3d.h"
#include "mesh.h"
#include "hierarchy_mesh.h"
#include "aabbtree.h"
#include "sparse_matrix.h"

#include "kdtree_old.h"

void test_matrix ()
{
	try
	{
		math::vector<double, 5> v51 ;
		math::vector<double, 3> v31 (1,2,3);
		math::vector<double, 3> v32 (1,2,4);

	
		math::vector<double, 3> v33 = v31^v32; 
		//matrix::vector<double, 3> v33= v31;
		std::cout<<v31<<v32<<v33<<std::endl;
		std::cout<<orient(v31, v32, v33)<<std::endl;
		std::cout<<"SIZE" <<v32.size()<<std::endl;
		std::cout<<"times "<<v32 * 3.3<<std::endl;
		v32 *=3.3 ; 
		
		math::matrix <double , 2, 2> m32 ; 
		
		m32[1][1] = 1; 
		//std::cout<<m32 (1,1)<<std::endl;

		math::matrix <double, 2, 2> m321 ;

		m321 = m32; 
		std::cout<<m321[1][1]<<std::endl;
		m321[1].y = 7;
		std::cout<<m321[1][1]<<std::endl;
		std::cout<<m32[1][1]<<std::endl;

		m321 = m321 + m32; 
		std::cout<<m321<<std::endl;
		math::matrix<double, 5, 5> m55 ;
		std::cout<<m55<<std::endl;
		std::cout<<m321.det()<<std::endl;
		math::matrix<double, 3, 3> m33 ;
		std::cout<<m33<<std::endl;

		m33[0][0] = m33[1][1]=m33[2][2] = 0.5; 
		std::cout<<m33.det()<<std::endl;
		std::cout<<m33.inv()<<std::endl;

		math::matrix<double, 2, 2> m22 ; 
		m22[0][0] = m22[1][1] = 0.7 ; 
		std::cout<<m22<<std::endl;
		std::cout<<m22.det()<<std::endl;
		std::cout<<m22.inv()<<std::endl;
		//std::cout<<m22 * 3.3<<std::endl;
		std::cout<<m22.inv() * m22<<std::endl; 

		math::matrix<double, 3, 2> newm32; 
		newm32 *= 4.3;
		std::cout<<newm32<<std::endl;
		std::cout<<newm32.transpose()<<std::endl;
		std::cout<<newm32 * newm32.transpose() <<std::endl;
		//std::cout<<m55.inv()<<std::endl;
		math::vector<math::vector <double , 3>, 5 > vv32 ;
		vv32 += 3.3;
		std::cout<<vv32<<std::endl;

		v32 = 1, 2;
		std::cout<<v32<<std::endl;
		v32 = 1, 2, 3;
		std::cout<<v32<<std::endl;

	}
	catch ( const char *msg)
	{
		std::cout<<"Exception : ";
		std::cout<<msg<<std::endl;
	}
}



void test_primitive()
{

	
	math::HierarchyMesh<math::mesh_traits<double, 3> > mesh ; 
	std::cin >> mesh; 

	mesh.build_hierarchy(); 
	mesh.rotateX (0.5);
	mesh.OBJ_writer (std::cout) ;

	math::vector<double, 3> center (3, 3, 3);
	double radius = 0.5; 
	math::Sphere <double, 3> sphere (center, radius) ;
	mesh.is_intersect(sphere);
	
/*
	math::vector<double, 3> v ;
	v[2] = 5; 
	std::cout<<v[2]<<std::endl;
	math::matrix <double, 3,3> m , n ; 
	m = 1, 2,3 , 0, 1,1, 0, 0, 2;
	n = m; 
	math::LU_Decomposor<double, 3> obj (m);
	std::cout<<obj.det()<<std::endl;
	obj.solve(m, n);
	std::cout<<n<<std::endl;
*/
}


void print (double v)
{
	std::cout<<v<<' ';
}
int main()
{
	//test_matrix();
	//test_primitive();
	

	return 0;
}
